package cn.coisini.model.dto;

import cn.coisini.model.common.annotation.State;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.groups.Default;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.URL;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author xiangshaw
 * Description: 文章信息
 */
@Tag(name = "文章信息")
@Getter
@Setter
public class ArticleDto {
    @Schema(description = "主键ID")
    @NotBlank(groups = {ArticleDto.Update.class}, message = "文章id不能为空")
    private String id;
    @Schema(description = "文章标题")
    @NotNull(message = "文章标题不能为空")
    @Pattern(regexp = "^\\S{1,20}$")
    private String title;
    @Schema(description = "文章内容")
    @NotNull(message = "文章内容不能为空")
    private String content;
    @Schema(description = "封面图像")
    @NotNull(message = "封面图像不能为空")
    @URL
    private String coverImg;
    @Schema(description = "发布状态  0 草稿、1 已发布、2 删除")
    @State
    private String state;
    @Schema(description = "文章分类名称id")
    @NotBlank(message = "文章分类不能为空")
    private String categoryId;
    @Schema(description = "文章标签ids")
    private List<String> tagIds;
    @Schema(description = "文章标签", hidden = false)
    private String tagName;
    @Schema(description = "文章标签颜色", hidden = false)
    private String tagColor;
    @Schema(description = "创建者id")
    private String createUser;
    @Schema(description = "创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING , pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime createTime;
    @Schema(description = "更新时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING , pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime updateTime;

    //自定义新增校验项分组（默认Default分组）
    public interface Add extends Default {
    }
    //自定义更新校验项分组
    public interface Update extends Default {
    }
}
